<template>
	<div class="w-page">
		<!-- 头部 -->
		<Header navNum="1"></Header>
		<!-- 内容 -->
		<div class="w-loginbox">
			<div class="w-width2">
				<div class="w-con flex hb vc">
					<div class="w-leftimgbox">
						<div class="w-leftimg"></div>
					</div>
					<div class="w-rightbox">
						<div class="w-logininput">
							<form action="form_action.asp" method="get">
								<h3 class="w-welcome">欢迎登录</h3>
								<div class="inputbox flex hs vc">
									<img src="../assets/img/index/login2.png" alt="">
									<input type="text" maxlength="11" placeholder='请输入账号' v-model="loginInfo.username">
								</div>
								<div class="inputbox flex hs vc">
									<img src="../assets/img/index/login3.png" alt="" >
									<input type="password" placeholder="请输入密码" v-model="loginInfo.password">
								</div>
								<div class="forgetbox flex hb vc">
									<label class="checkbox flex vc">
										<div class="chec">
											<input type="checkbox" />
											<div class="nochoose">
												<span>✔</span>
											</div>
										</div>
										<span class="rember">记住密码</span>
									</label>
									<div class="w-forgetbox flex vc">
										<router-link to="/reset" class="forget">忘记密码？</router-link>
										<span class="reg" style="cursor: pointer;" @click="toRegister">注册</span>
									</div>
								</div>
								<div class="rebtn" @click="onSubmit()">登录</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import axios from 'axios';
	import { registered, login } from '@/api/login'
	import { setAdminToken } from '@/utils/auth'
	export default {
		name: "from",
		data() {
			return {
				loginInfo: {
					"username": "",
					"password": ""
				}
			};
		},

    methods: {
			onSubmit() {
				 login(this.loginInfo).then(response => {
				  setAdminToken(response.data.token)
				  this.$router.push({ path: '/' })
				})
			},

      // 去注册
      toRegister(){
        // 事件触发 显示注册模态框
        this.$eventBus.$emit('isShowCodeDialog', true, true)
      }
		}
	};
</script>

<style scoped>
	.w-page {
		height: 100vh;
		width: 100vw;
		overflow: hidden;
	}

	.w-loginbox {
		width: 100%;
		height: calc(100vh - 136px);
		background-color: #DDC4A6;
		background-size: cover;
		background-position: center;
	}

	.w-width2 {
		width: 60%;
		margin: 0 auto;
		padding-top: 70px;
		padding-bottom: 110px;
		box-sizing: border-box;
		height: 100%;
	}

	.w-con {
		background: #fff;
		/* height: 100%; */
		border-radius: 10px;
	}

	.w-con .w-leftimgbox {
		width: 55%;
		height: 100%;
		padding-left: 75px;
		/* 	padding-top: 70px;
		padding-bottom: 80px; */
		box-sizing: border-box;
	}

	.w-con .w-leftimg {
		height: 100%;
		width: 100%;
		min-height: 20vw;
		box-sizing: border-box;
		display: block;
		background-image: url(../assets/img/index/login1.png);
		background-size: contain;
		background-position: center;
		background-repeat: no-repeat;
	}

	.w-rightbox {
		margin: 5vw auto;
		width: 45%;
		min-height: 20vw;
	}

	.w-welcome {
		font-size: 28px;
		font-weight: 600;
		color: rgba(255, 255, 255, 1);
		background: linear-gradient(-70deg, rgba(207, 169, 114, 1) 0%, rgba(235, 219, 194, 1) 100%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
		margin-bottom: 30px;
	}

  _:-ms-fullscreen, :root .w-welcome {
    background: #ffffff;
    color: rgba(207, 169, 114, 1);
  }

	.w-rightbox img {
		width: 18px;
		height: 26px;
		display: block;
		margin-right: 18px;
	}

	.inputbox {
		margin-bottom: 15px;
		padding: 19px 0;
		border-bottom: 1PX solid #ddd;
	}

	.w-logininput {
		width: 60%;
		margin: 0 auto;
	}

	.inputbox input {
		font-size: 16px;
		border: none;
		font-weight: 300;
		color: rgba(153, 153, 153, 1);
	}

	.forget {
		font-size: 12px;
		font-weight: 300;
		display: block;
		color: rgba(102, 102, 102, 1);
	}

	.rebtn {
		width: 100%;
		background: linear-gradient(90deg, rgba(214, 185, 143, 1), rgba(207, 169, 114, 1));
		border-radius: 10px;
		color: #fff;
		font-size: 18px;
		font-weight: 400;
		outline: none;
		border: none;
		padding: 16px 0;
		line-height: 1;
		margin-top: 55px;
		text-align: center;
    cursor: pointer;
	}

	.rember {
		font-size: 12px;
		font-weight: 300;
		color: rgba(102, 102, 102, 1);
	}

	.chec {
		position: relative;
		margin-right: 12px;
	}

	.chec input {
		position: absolute;
		top: 0;
		opacity: 0;
		outline: none;
	}

	input:focus {
		outline: none;
		border: none;
	}

	.chec input:checked+.nochoose span {
		opacity: 1;
	}

	.nochoose {
		border: 1PX solid #999;
		background: #fff;
		width: 14px;
		height: 14px;
		border-radius: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
	}

	.nochoose span {
		opacity: 0;
		width: 14px;
		text-align: center;
		display: block;
	}

	.reg {
		font-size: 14px;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
		display: block;
		padding-bottom: 2px;
	}

	.forgetbox {
		margin-bottom: 15px;
		padding: 19px 0;
	}
</style>
